<#assign ctx="${request.contextPath}" />
<#assign shiro=JspTaglibs["/WEB-INF/taglib/shiro.tld"] />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="${ctx}/static/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/static/js/jquery.js"></script>
</head>

<body>

	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
		    <li><a href="#">首页</a></li>
		    <li><a href="#">增加用户</a></li>
	    </ul>
    </div>
    <input type="hidden" name="errorCode" id="errorCode" value="${errorCode}"/>
	<input type="hidden" name="errorMessage" id="errorMessage" value="${errorMessage}"/>
    <div class="formbody">
    	<div class="formtitle"><span>增加信息</span></div>
    	<form action="${ctx}/user/update" method="post" id="form">
    		<input id="id" name="id" value="${user.id}" type="hidden"/>
		    <ul class="forminfo">
			    <li><label>用户名<b>*</b></label><input name="userName" id="userName" type="text" class="dfinput" value="${user.userName}"/><i class="nameMessage"></i></li>
			    <li><label>密码<b>*</b></label><input name="password" id="password" type="text" class="dfinput"  value="******"/><i class="pwdMessage"></i></li>
			    <li><label>真实姓名<b>*</b></label><input name="realName" id="realName" type="text" class="dfinput"  value="${user.realName}"/><i class="realMessage"></i></li>
			    <li><label>手机号<b>*</b></label><input name="mobile" id="mobile" type="text" class="dfinput" value="${user.mobile}" /><i class="mobileMessage"></i></li>
			    <li><label>锁定状态</label>
				    <cite>
				    <input name="locked" type="radio" value="0" <#if !(user.locked)>checked="checked"</#if> />否&nbsp;&nbsp;&nbsp;&nbsp;
				    <input name="locked" type="radio" value="1" <#if user.locked>checked="checked"</#if> />是
				    </cite>
			    </li>
			    <li><label>权限角色</label>
			    	<div class="cityleft">
				    	<div class="uew-select">
				    		<div class="uew-select-value ue-state-default">
						    <select name="roleId" id="roleId" class="select1">
						    
							    <option <#if (user.roleId??) || (user.roleId!'')==0>selected="selected"</#if> value="">请选择</option>
							    <#list roleList as role>
							    <option value="${role.id}" <#if (user.roleId!'')==role.id  >selected="selected"</#if>>${role.name}</option>
							    </#list>
						    </select>
						    </div>
					    </div>
				    </div>
				    <i class="roleIdMessage"></i>
			    </li>
			    <li><label>&nbsp;</label><input name="" id="preservation" type="button" class="btn" value="确认保存"/></li>
		    </ul>
		 </form>
    </div>
     <div class="tip">
    		<div class="tiptop"><span>提示信息</span><a></a></div>
	      	<div class="tipinfo">
		        <div class="tipright">
			        <p class="errormMssage"></p>
		        </div>
		    </div>
	        <div class="tipbtn">
		        <input name="" type="button"  class="sure" value="确定" />&nbsp;
		        <input name="" type="button"  class="cancel" value="取消" />
        	</div>
    
    </div>
    <script>
	    $('.btn').click(function(){
	    	var userName = $("#userName").val().replace(/\s/g,"");
	    	var password = $("#password").val().replace(/\s/g,"");
	    	var realName = $("#realName").val().replace(/\s/g,"");
	    	var mobile = $("#mobile").val().replace(/\s/g,"");
	    	var roleId = $("#roleId option:selected").val().replace(/\s/g,"");
	    	//boolean nstatus = false;
	    	if(null == userName || userName == ''){
	    		$(".nameMessage").html("用户名不能为空！");
	    		return false;
	    	}
	    	if(null == password || password == ''){
	    		$(".pwdMessage").html("密码不能为空！");
	    		return false;
	    	}
	    	if(null == realName || realName == ''){
	    		$(".realMessage").html("用户真实姓名不能为空！");
	    		return false;
	    	}
	    	if(null == mobile || mobile == ''){
	    		$(".mobileMessage").html("用户名手机号码不能为空！");
	    		return false;
	    	}
	    	if(null == roleId || roleId == ''){
	    		$(".roleIdMessage").html("请选择用户角色！");
	    		return false;
	    	}
	    	if(null != userName && userName != '' && null != password && password != '' && null != realName && realName != '' && null != mobile && mobile != '' && null != roleId && roleId != ''){
	    		$("#form").submit();
	    	}else{
	    		$(".errorMessage").html("请填写不能为空的字段值！");
	    		$(".tip").fadeIn(200);
	    	}
		});
	   	$(".tiptop a").click(function(){
	   	  $(".tip").fadeOut(200);
	   	});
	
	   	  $(".sure").click(function(){
	   	  $(".tip").fadeOut(100);
	   	});
	
	   	  $(".cancel").click(function(){
	   	  $(".tip").fadeOut(100);
	   	});
	   	$(function(){
			 var errorCode = $("#errorCode").val();
			 var errorMessage = $("#errorMessage").val();
			 if(null != errorCode && errorCode != ""){
				 $(".errormMssage").html(errorMessage);
				 $(".tip").fadeIn(200);
			 }
		});
    </script>
</body>
</html>
